<template>
  <header :class="{turnContext:$store.state.route.meta.turnContext}">
    <div class="heder-wrap flex position" :class="{noBorder:$store.state.route.meta.noBorder}">
      <span class="left_btn" @click="backUrl" v-if="!$store.state.route.meta.noLeft"></span>
      <p class="cell_1 center_content font18" >{{headText}}</p>
      <template v-for="_item in $route.meta['titleBtn']">
        <span class="right_btn font16" :key="_item.btnName" @click="triggerCallBack" :class="_item.className" ref='rightBtn' >{{headerBtn.btnClick.BtnText || _item.btnName}}</span>
      </template>
    </div>
  </header>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import Base64 from 'lib/base64'
export default {
  data () {
    return {
      isDelive: ''
    }
  },
  computed: {
    ...mapGetters({
      headerBtn: "getheaderBtn"
    }),
    headText () {
      return this.$store.state.route.meta.title
    }
  },
  methods: {
    ...mapActions([
      "updateheaderBtn"
    ]),
    backUrl () {
      let callBackUrl = window.sessionStorage.getItem('callBackUrl')
      if (callBackUrl) {
        window.location.href = Base64.decode(callBackUrl)
      } else {
        window.history.go(-1)
      }
    },
    triggerCallBack () {
      let { btnCallBack } = this.headerBtn.btnClick
      btnCallBack && btnCallBack()
    }
  }
}
</script>
